<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" >
<head>
    <th:block th:include="include :: header('新增用户')" />
    <th:block th:include="include :: select2-css" />
</head>
<body>
<div class="main-content">
    <form enctype="multipart/form-data" class="mt20 mb10">
        <div class="col-xs-offset-1">
            <input type="file" id="file" name="file" multiple onchange="getUrl(this)"/>
            <div class="mt10 pt5">
                <input type="checkbox" id="updateSupport" name="updateSupport" title="如果登录账户已经存在，更新这条数据。"> 是否更新已经存在的用户数据
                &nbsp;	<a onclick="downloadTemplate()" class="btn btn-default btn-xs"><i class="fa fa-file-excel-o"></i> 下载模板</a>
            </div>
            <font color="red" class="pull-left mt10">
                提示：仅允许导入“xls”或“xlsx”格式文件！
            </font>
        </div>
    </form>
</div>
<th:block th:include="include :: footer" />
<th:block th:include="include :: select2-js" />
<script th:inline="javascript">
    var prefix = ctx + "wstudy/student";
    var uploadMaterialDataUrl = prefix+"/importData";
    function submitHandler() {
        alert("ok")
    }
    function downloadTemplate(){
        let url = "/templates/student.xlsx";
        let name = "导入学生数据模板.xlsx"
        window.location.href =  "/wstudy/student/downloadTemplate?resource=" + url+"&downloadName="+name;
    }
    function getUrl(node) {
        var dom = document.getElementById("file");
        console.log(dom)
        console.log(dom.files[0])
    }
    var input = document.getElementsByTagName("input")[0];
    console.log(input);
    input.onchange = function () {
        var that = this;
        console.log(that.files[0]);
        var src = window.URL.createObjectURL(that.files[0])
        console.log(src);
        // var img = document.createElement("img");
        // img.style.width = "200px";
        // img.src = src;
        // document.body.appendChild(img);
    }
</script>
</body>
</html>